[emval] Support dynamically-typed conversion to/from val #24790
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
...for cases where a dynamically given user-defined type is known to be ABI-compatible with a statically given wire type (e.g., an enum type being compatible with its underlying type, or a struct type being compatible with
const void*
; for the latter, a returnedconst void*
needs to be transformed somehow into the desired dynamic type before destructors are run and the pointed-to object is destroyed).In LibreOffice, I have a scenario where I combine
val
with a C++Any
type that dynamically knows what type it holds, which does not fit with the statically typedval
constructor andas
getter. Prior to d8dda21 "[embind] Use a single invoker mechanism (#24577)", I had tapped into the internals ofemscripten/val.h
(https://git.libreoffice.org/core/+/c35985a4b42d6a7d654b4fd1f99a966b75ee28a6%5E%21 "Embind construction of UNO Any enum", https://git.libreoffice.org/core/+/2995a0e0785911322c9d57e98b925073ff6cb6bd%5E%21 "Embind construction of UNO Any sequence/struct/exception/interface"), which no longer works. So I'm proposing here adding the relevant code (which only makes sense for__has_feature(cxx_rtti)
) to Emscripten.(The JS code now needs to keep track and reuse generated method callers. I have no idea how better to implement in JS such a lookup map from signatures (tuples of
EM_INVOKER_KIND
values and argument types) to method caller IDs, other than going via a cheesy string representation?)